package com.service.impl;

import com.bean.Orders;
import com.bean.User;
import com.dao.UserMapper;
import com.service.UserService;

import org.springframework.data.relational.core.sql.In;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Samsara
 * @description 针对表【user】的数据库操作Service实现
 * @createDate 2023-01-18 03:31:01
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public Integer insertBatch(List<User> userList) {
        userList.forEach(
                item-> {
                    item.setPassword(DigestUtils.md5DigestAsHex(item.getPassword().getBytes()));
                }
        );
        return userMapper.insertBatch(userList);
    }

    @Override
    public Integer updateBatch(List<User> userList) {
        userList.forEach(
                item-> {
                    item.setPassword(DigestUtils.md5DigestAsHex(item.getPassword().getBytes()));
                }
        );
        return userMapper.updateBatch(userList);
    }

    @Override
    public Integer deleteBatch(List<User> userList) {
        return userMapper.deleteBatch(userList);
    }

    @Override
    public List<User> selectUserList(List<User> userList, Integer start, Integer end) {
        return userMapper.selectUserList(userList,start,end);
    }

    @Override
    public List<User> selectUserListAndRoleList(List<User> userList, Integer start, Integer end) {
        return userMapper.selectUserListAndRoleList(userList,start,end);
    }

    @Override
    public List<User> selectUserListAndOrderList(List<User> userList, Integer start, Integer end) {
        return userMapper.selectUserListAndOrderList(userList,start,end);
    }

    @Override
    public List<User> selectUserListAndSeckillList(List<User> userList, Integer start, Integer end) {
        return userMapper.selectUserListAndSeckillList(userList,start,end);
    }
}
